home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / fractals / apfelkiste / apfelkiste2.0 / source / apfelkiste2.0src.lzh / Fixpoint030.a < prev    next >
Text File  |  1991-07-21  |  2KB  |  87 lines

  1. ** With this file I supply 68030 fixpoint calculation. To use this
  2. ** instead of the normal 68000 function, assemble it via
  3. **         asm -m2 fixpoint030
  4. ** You then should set the 68030 option with the Options program
  5. ** and click on the "build" icon.
  6. ** The function is short enough to fit completely into the 68030
  7. ** program cache and should be *REALLY* fast.
  8.  
  9.     CSECT    DATA,1,,2,2
  10.  
  11.     XREF    _maxcol
  12.     XREF    _MAXITER
  13.  
  14.     CSECT    TEXT,0,,1,2
  15.  
  16.     XDEF    _Iter_FXP
  17.  
  18. _Iter_FXP:
  19.     movem.l    D3-D7,-(SP)        ;save registers
  20.     move.l    D1,D3            ;p = r
  21.     move.l    D2,D4            ;q = i
  22.     move.w    _MAXITER(A4),D0
  23.     ext.l    D0
  24.  
  25. __while:
  26.     move.l    D1,D6            ;calc. r²
  27.     muls.l    D1,D5:D6
  28.     asl.l    #8,D5            ;normalize
  29.     rol.l    #8,D6
  30.     move.b    D6,D5
  31.  
  32.     move.l    D2,D7            ;calc. i²
  33.     muls.l    D2,D6:D7
  34.     asl.l    #8,D6            ;normalize
  35.     rol.l    #8,D7
  36.     move.b    D7,D6
  37.  
  38.     add.l    D6,D5
  39.  
  40. ;now D5 contains r²+i²
  41.  
  42.     cmp.l    A2,D5            ;test for upper bound
  43.     bge    __done            ;exceeded => end
  44.  
  45.     move.l    D1,D5            ;calc. x+i
  46.     add.l    D2,D5
  47.  
  48.     move.l    D1,D6            ;calc. x-i
  49.     sub.l    D2,D6
  50.  
  51.     muls.l    D5,D5:D6        ;calc. (x+i)*(x-i)
  52.     asl.l    #8,D5            ;normalize
  53.     rol.l    #8,D6
  54.     move.b    D6,D5
  55.  
  56.     add.l    D3,D5            ;add p
  57.  
  58. ;D5 now contains (x+i)(x-i)+p
  59.  
  60.     muls.l    D1,D6:D2        ;calc. 2xi+q
  61.     asl.l    #8,D6            ;normalize
  62.     rol.l    #8,D2
  63.     move.b    D2,D6
  64.     add.l    D6,D6            ;*2
  65.     add.l    D4,D6            ;add q
  66.  
  67. ;D6 now contains 2xi+q
  68.  
  69.     move.l    D5,D1            ;r = (x+i)(x-i)+p
  70.     move.l    D6,D2            ;i = 2xi+q
  71.  
  72.     dbra    D0,__while        ;to start of loop
  73.  
  74.     moveq    #0,D0            ;return 0, if MAXITER was exceeded
  75.     movem.l    (SP)+,D3-D7
  76.     rts
  77.  
  78. __done:
  79.     divu.w    _maxcol(A4),D0        ;return ( count % maxcol )
  80.     clr.w    D0
  81.     swap    D0
  82.  
  83.     movem.l    (SP)+,D3-D7
  84.     rts
  85.  
  86.     END
  87.